/**
 * InstanceOfMatcher.java
 * 
 * Created on Jul 5, 2008 at 10:22:39 AM
 */
package org.lego4j.matchers;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

/**
 * TODO add javadoc to InstanceOfMatcher
 *
 * @author <a href="alexguev@gmail.com">Alexei Guevara</>
 * @version $Revision:$ updated on $Date:$ by $Author:$
 */
public class InstanceOfMatcher<T> extends TypeSafeMatcher<T> {
    
    private Class<T> myInstanceType;

    public InstanceOfMatcher( Class<T> theInstanceType ) {
        myInstanceType = theInstanceType;
    }

    @Override
    public boolean matchesSafely(T theInstance) {
        return true;
    }

    public void describeTo(Description theDescription) {
        theDescription.appendText( "InstanceOf " + myInstanceType );
    }
    
    public static <T> Matcher<T> instanceOf( Class<T> theInstanceType ) {
        return new InstanceOfMatcher<T>( theInstanceType );
    }

}
